package com.daocao.yfb.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;



import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import com.daocao.yfb.R;
import com.daocao.yfb.activity.ForgetPassActivity;
import com.daocao.yfb.activity.LoginActivity;
import com.daocao.yfb.constant.Const;
import com.daocao.yfb.util.ToastUtil;
import com.daocao.yfb.util.UI;
import com.daocao.yfb.util.Util;

/**
 * Created by xsooy-pc on 17-12-4.
 */

public class LoginByPassFragment extends BaseFragment {
    @BindView(R.id.edit_phone)
    EditText editPhone;
    @BindView(R.id.edit_pass)
    EditText editPass;
    @BindView(R.id.btn_forget)
    TextView btnForget;
    @BindView(R.id.btn_submit)
    TextView btnSubmit;
    Unbinder unbinder;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_login_pass;
    }

    @Override
    protected void initView() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.btn_forget, R.id.btn_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_forget:
                Util.startActivity(getActivity(), ForgetPassActivity.class);
                break;
            case R.id.btn_submit:
                if (TextUtils.isEmpty(UI.toString(editPhone))) {
                    ToastUtil.makeText(getContext(), "手机号不能为空");
                    return;
                }
                if (TextUtils.isEmpty(UI.toString(editPass))) {
                    ToastUtil.makeText(getContext(), "密码不能为空");
                    return;
                }
                ((LoginActivity) getActivity()).getLoginByPwd(UI.toString(editPhone), UI.toString(editPass));
                break;
        }
    }
}
